﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBCommon;

namespace DreamsI.EduSpon
{
    public partial class _Default : eduSponCommon
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            using (JSONCommon.JSON_Converter jsonConvert = new JSONCommon.JSON_Converter())
            {
                #region 객체확인

                string sType = Request.RequestType;
                string sParams = "";

                if (sType == "GET")
                {
                    sParams = Request.QueryString["param"];
                }
                else
                {
                    sParams = Request.Form["param"];
                }

                #endregion




                try
                {

                    //복호화
                    if (bool.Parse(ConfigurationSettings.AppSettings["SecurityFlag"].ToString()))
                    {
                        this.RijndaelManagedString(sParams, "");
                    }


                    SqlConnection conn = new SqlConnection();
                    DataSet dsParam = null;
                    DataSet dsResult = null;
                    string sResult = string.Empty;

                    using (DBCommon.DBConnect dbConnect = new DBConnect())
                    using (JSONCommon.JSON_Converter JsonConverter = new JSONCommon.JSON_Converter())
                    {
                        //JSON 문자열 변환
                        dsParam = JsonConverter.JsonStringToDataSet(sParams);

                        //SqlConnection 생성
                        conn = dbConnect.CreateConnection(dsParam.Tables[0].Rows[0]["CONTYPE"].ToString());


                        //sp호출후 결과값 저장
                        dsResult = null;
                        sResult = JsonConverter.DataSetToJson(dsResult);


                    }

                    //암호화                
                    if (bool.Parse(ConfigurationSettings.AppSettings["SecurityFlag"].ToString()))
                    {
                        this.RijndaelManagedString(sResult, "e");
                    }

                    Response.Write(sResult);
                    conn.Close();
                }
                catch (Exception ex)
                {

                }
                finally
                {

                }

            }
            



            
        }
    }
}